<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<%--将理发项目的次数 由创建用户vip时根据充值的金额自动计算，还有后续再次充值及消费后均自动计算次数并保存--%>
<head>
	<meta charset="utf-8">
    <base href="http://localhost:8080/Barbr/">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>添加会员</title>
	<link rel="stylesheet" href="layui-v2.6.8/layui/css/layui.css">
    <link rel="stylesheet" href="css/addMembership.css">
    <link rel="shortcut icon" href="img/hair.png">
    <script src="js/common.js"></script>
    <script src="http://static.runoob.com/assets/vue/1.0.11/vue.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
    <script src="js/jquery-1.12.4.min.js"></script>
    <script src="js/add.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
	<div class="layui-header">
		<div class="layui-logo layui-hide-xs layui-bg-black">H·Y</div>
		<!-- 头部区域（可配合layui 已有的水平导航） -->
		<ul class="layui-nav layui-layout-right">
			<li class="layui-nav-item layui-hide layui-show-md-inline-block">
				<a href="javascript:;">
					<img src="img/geren.png" class="layui-nav-img">
                    <span id="username"><%=session.getAttribute("username")%></span>
				</a>
				<dl class="layui-nav-child">
					<dd><a href="html/Personal_Information.jsp">个人信息</a></dd>
					<dd><a href="logout">退出登录</a></dd>
				</dl>
			</li>
			<li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
				<a href="javascript:;">
					<i class="layui-icon layui-icon-more-vertical"></i>
				</a>
			</li>
		</ul>
	</div>

	<div class="layui-side layui-bg-black">
		<div class="layui-side-scroll">
			<ul class="layui-nav layui-nav-tree" lay-filter="test">
				<li class="layui-nav-item layui-nav-itemed">
					<a class="layui-nav-item" href="html/MembershipManagement.jsp">会员管理</a>
				</li>
                <li class="layui-nav-item">
                    <a href="html/investMoney.jsp">充值与查询</a>
                </li>
				<li class="layui-nav-item">
					<a href="html/addMembership.jsp">办理会员卡</a>
				</li>
				<li class="layui-nav-item">
					<a href="html/operation.jsp">会员操作记录</a>
				</li>
				<li class="layui-nav-item"><a href="html/Personal_Information.jsp">个人信息</a></li>
			</ul>
		</div>
	</div>

	<div class="layui-body" style="height: 100%;">
    <div id="title"><h2>会 员 信 息 录 入</h2></div>
    <hr/>
		<div id="addmembership">
            <form class="layui-form" action="" id="form">
                <div class="layui-form-item">
                  <label class="layui-form-label">顾客姓名</label>
                  <div class="layui-input-block">
                    <input type="text" name="title"  id="customerName"  maxlength="10" autocomplete="off" placeholder="请输入姓名" class="layui-input" value="剑姬" style="width: 16%; min-width: 190px;">
                  </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                      <input type="radio" name="sex" id="man" value="男" title="男" checked="checked">
                      <input type="radio"  name="sex" id="woman"  value="女" title="女">
                    </div>
                  </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">手机号码</label>
                    <div class="layui-input-inline">
                      <input type="tel" name="phone"  id="phoneNumber" autocomplete="off" value="15189655869" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                  </div>
                </div>
                
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">注册日期</label>
                    <div class="layui-input-inline">
                      <input type="text" name="date" id="input"  placeholder="yyyy-MM-dd" class="layui-input" autocomplete="false" style="width: 16%; min-width: 190px;">
                    </div>
                  </div>
                </div>
                <div class="layui-form-item" >
                    <label class="layui-form-label">会员卡类型</label>
                    <div class="layui-input-block" id="barbertime">
                      <select name="project" id="project">
                        <option value=""></option>
                        <option value="0" selected>剪发</option>
                        <option value="1">洗发</option>
                        <option value="2">护理</option>
                        <option value="3">补发根</option>
                        <option value="4">染发</option>
                        <option value="5">黑油</option>
                        <option value="6">烫发+剪发</option>
                        <option value="7">烫发+染发</option>
                        <option value="8">洗发+染发</option>
                        <option value="9">剪发+黑油</option>
                        <option value="10">剪发+染发</option>
                      </select>
                    </div>
                  </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">金额（元）</label>
                    <div class="layui-input-block">
                      <input type="text" value="0" disabled name="title" maxlength="10" id="Consumption" autocomplete="off" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">剪发次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11" name="title" id="cutnum"  maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                    <label class="layui-form-label">烫发次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11" name="title" id="permnum"  maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                    <label class="layui-form-label">护理次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11"  name="title" id="nusenum" maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                    <label class="layui-form-label">补发根次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11"  name="title" id="rootnum" maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                    <label class="layui-form-label">染发次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11"  name="title" id="dyenum" maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                    <label class="layui-form-label">洗发次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11"  name="title" id="washnum"  maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                    <label class="layui-form-label">黑油次数</label>
                    <div class="layui-input-inline">
                      <input type="text" value="11"  name="title" id="blacknum" maxlength="5" autocomplete="off" placeholder="0" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">充值卡金</label>
                    <div class="layui-input-block">
                      <input type="text" value="100"  name="title" id="amount"  required maxlength="10" autocomplete="off" placeholder="请输入金额" class="layui-input" style="width: 16%; min-width: 190px;">
                    </div>
                  </div>
                <div class="layui-form-item layui-form-text">
                  <label class="layui-form-label">备注</label>
                  <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" value="11"  id="notes"></textarea>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button type="button" onclick="addUser()" class="layui-btn">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                  </div>
                </div>
              </form>
        </div>
	</div>

  <div class="layui-footer" style="text-align:center;">
    H·Y
    </div>
</div>
<script src="layui-v2.6.8/layui/layui.js"></script>
<script>
    let price = {};
    var Consumption = document.querySelector('#amount');
    var cutnum = document.querySelector('#cutnum');
    var permnum = document.querySelector('#permnum');
    var nusenum = document.querySelector('#nusenum');
    var rootnum = document.querySelector('#rootnum');
    var dyenum = document.querySelector('#dyenum');
    var washnum = document.querySelector('#washnum');
    var blacknum = document.querySelector('#blacknum');
    Consumption.onblur = function(){
        if (price == null || price == "" || price){
            $.ajax({
                url:"http://localhost:8080/Barbr/getPrice",
                type:"get",
                cache:false,
                data:{},
                dataType:"json",
                success(data){
                    price = data;
                },
                error(){
                    alert("err");
                }
            });
        }
        setTimeout(()=>{
            cutnum.value = parseInt(Consumption.value / price.haircut);
            permnum.value = parseInt(Consumption.value / price.perm);
            nusenum.value = parseInt(Consumption.value / price.wash_protect);
            rootnum.value = parseInt(Consumption.value / price.hairroot);
            dyenum.value = parseInt(Consumption.value / price.colour);
            washnum.value = parseInt(Consumption.value / price.wash);
            blacknum.value = parseInt(Consumption.value / price.black);
        },1000);



    }


	//JS
	layui.use(['element', 'layer', 'util'], function(){
		var element = layui.element
			,layer = layui.layer
			,util = layui.util
			,$ = layui.$;

		//头部事件
		util.event('lay-header-event', {
			//左侧菜单事件
			menuLeft: function(othis){
				layer.msg('展开左侧菜单的操作', {icon: 0});
			}
			,menuRight: function(){
				layer.open({
					type: 1
					,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
					,area: ['260px', '100%']
					,offset: 'rt' //右上角
					,anim: 5
					,shadeClose: true
				});
			}
		});

	});
  var _input = document.getElementById('input');

var date = new Date();
var seperator = "/";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
    month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;
}
var currentDate = year + seperator + month + seperator + strDate; //当前日期

_input.value = currentDate; //赋值给input.value
_input.setAttribute('disabled', 'disabled'); //不可编辑
</script>
</body>
</html>
